import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalMynewPage(Base):
    """
     我的消息界面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.new_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.new_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 标题图标
        self.new_title_lift_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_mine_message_title_voice"))

        # 标题提示语
        self.new_title_right_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_mine_message_title"))

        # 反馈结果图标
        self.new_list_message_reply_icon = (By.XPATH, Personal.my_new_list_feed_icon.format(""))

        # 反馈结果标题
        self.new_list_message_reply_title_text = (By.XPATH, Personal.my_new_list_feed_title_text.format(""))

        # 反馈结果回复
        self.new_list_specific_news_text = (By.XPATH, Personal.my_new_list_feed_reply_text.format(""))

        # 反馈消息未读图标
        self.new_unread_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_message_point"))

        # 消息列表选中框
        self.new_list_my_new_select = (By.XPATH, Personal.my_new_list_feed_select.format(""))

        # 不存在消息
        self.new_no_new_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_exception_desc"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.new_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.new_back_btn)

    def get_title_lift(self):
        """
        获取反馈消息标题图标

        :return:获取元素
        """
        return self.find_element_o(self.new_title_lift_icon)

    def get_title_right(self):
        """
        获取反馈消息标题

        :return:获取元素
        """
        return self.find_element_o(self.new_title_right_text)

    def get_list_message_reply(self, index=1):
        """
        获取反馈消息结果图标
        index 为反馈消息条数,默认为第一条
        :return:获取元素
        """
        self.new_list_message_reply_icon = (By.XPATH, Personal.my_new_list_feed_icon.format(index))
        return self.find_element_o(self.new_list_message_reply_icon)

    def get_list_message_reply_title(self, index=1):
        """
        获取反馈消息结果标题
        index 为反馈消息条数,默认为第一条
        :return:获取元素
        """
        self.new_list_message_reply_title_text = (By.XPATH, Personal.my_new_list_feed_title_text.format(index))
        return self.find_element_o(self.new_list_message_reply_title_text)

    def get_list_specific_news(self, index=1):
        """
        获取反馈消息结果
        index 为反馈消息条数,默认为第一条
        :return:获取元素
        """
        self.new_list_specific_news_text = (By.XPATH, Personal.my_new_list_feed_reply_text.format(index))
        return self.find_element_o(self.new_list_specific_news_text)

    def click_list_specific_news(self, index=1):
        """
        点击反馈列表
        index 为反馈消息条数,默认为第一条
        :return:None
        """
        self.new_list_specific_news_text = (By.XPATH, Personal.my_new_list_feed_reply_text.format(index))
        self.click_element(self.new_list_specific_news_text)

    def get_list_my_new(self, index=1):
        """
        获取反馈列表属性
        index 为反馈消息条数,默认为第一条
        :return:获取元素
        """
        self.new_list_my_new_select = (By.XPATH, Personal.my_new_list_feed_select.format(index))
        return self.find_element_o(self.new_list_my_new_select)

    def get_unread(self):
        """
        获取未读消息图标

        :return:获取元素
        """
        return self.find_element_o(self.new_unread_icon)

    def is_display_personal_new_feed(self):
        """
        是否存在反馈结果界面

        :return: bool
        """
        return self.is_display(self.new_title_right_text)

    def is_display_personal_my_new(self):
        """
        是否存在消息

        :return: bool
        """
        return self.is_display(self.new_no_new_text)

